package com.mobilesafe.ui;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.TextView;

import com.mobilesafe.R;
import com.mobilesafe.adapter.MainUIAdapter;
import com.mobilesafe.base.BaseActivity;

public class MainActivity extends BaseActivity implements OnItemClickListener {
	private static final String TAG = "MainActivity";
	private GridView gv_main;
	private LayoutInflater inflater;
	private TextView tv_title_text;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		// 取消标题栏
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		findViewById();
		gv_main = (GridView) findViewById(R.id.gv_main);
		MainUIAdapter adapter = new MainUIAdapter(this);
		gv_main.setAdapter(adapter);
		gv_main.setOnItemClickListener(this);

	}

	@Override
	protected void findViewById() {
		// TODO Auto-generated method stub
//		inflater= LayoutInflater.from(this);
//		View view= inflater.inflate(R.layout.title_bar, null);
//		tv_title_text = (TextView) view.findViewById(R.id.tv_title_text);
//		tv_title_text.setText("222");

	}

	@Override
	protected void initView() {
		// TODO Auto-generated method stub

	}
	/**
	 * 当gridview的条目被点击的时候 对应的回调 parent :　girdview view : 当前被点击的条目 Linearlayout
	 * position : 点击条目对应的位置 id : 代表的行号
	 */
	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id) {
		Log.i(TAG, "点击的位置" + position);
		switch (position) {
		case 0: // 手机防盗
			Log.i(TAG, "进入手机防盗");
			Intent lostIntent = new Intent(MainActivity.this, LostProtectedActivity.class);
			startActivity(lostIntent);
			break;

		}
		
	}

}
